Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
extend-shallow
Advanced tools
Extend an object with the properties of additional objects. node.js/javascript util.
The extend-shallow npm package is used to copy the properties of one or more source objects to a target object. It is a utility for shallowly extending the properties of objects without deeply cloning them.
Shallow extend one object with another
This feature allows you to extend an object by adding properties from another object. The properties are copied over shallowly, meaning that if the property values are objects, they are not deeply cloned.
{"const extend = require('extend-shallow');
const obj1 = { a: 'a' };
const obj2 = { b: 'b' };
const result = extend(obj1, obj2);
// result is { a: 'a', b: 'b' }"}
Shallow extend with multiple source objects
This feature allows you to extend an object with properties from multiple source objects. The last source's properties will overwrite the properties of the same name in previous sources if they exist.
{"const extend = require('extend-shallow');
const obj1 = { a: 'a' };
const obj2 = { b: 'b' };
const obj3 = { c: 'c' };
const result = extend(obj1, obj2, obj3);
// result is { a: 'a', b: 'b', c: 'c' }"}
The object-assign package is a polyfill for the Object.assign() method, which copies enumerable and own properties from source objects to a target object. It is similar to extend-shallow but is designed to mimic the behavior of the native JavaScript method.
lodash.assign is a method from the Lodash library that assigns own enumerable properties of source objects to the destination object. It is similar to extend-shallow but comes with the additional utility functions provided by Lodash.
deep-extend is similar to extend-shallow but, as the name suggests, performs a deep extend, meaning that it recursively copies property values that are objects, resulting in a deep clone of the source objects' properties.
Extend an object with the properties of additional objects. node.js/javascript util.
Install with npm
$ npm i extend-shallow --save
Install dev dependencies:
$ npm i -d && npm test
var extend = require('extend-shallow');
extend({a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
Pass an empty object to shallow clone:
var obj = {};
extend(obj, {a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
Object
constructor.Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on May 21, 2015.
FAQs
Extend an object with the properties of additional objects. node.js/javascript util.
The npm package extend-shallow receives a total of 25,127,349 weekly downloads. As such, extend-shallow popularity was classified as popular.
We found that extend-shallow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.